package com.han.hotelplat.service.hhm.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.han.hotelplat.dao.hhm.HotelHmanagerDao;
import com.han.hotelplat.pojo.hhm.HotelHmanager;
import com.han.hotelplat.service.hhm.HotelHmanagerService;

@Service
public class HotelHmanagerServiceImpl implements HotelHmanagerService{
	@Autowired
	private HotelHmanagerDao dao;
	
	public List<HotelHmanager> getBindHotelManager(Integer hotelId,
			String userid, Integer state) {
		String hql = " from HotelHmanager where 1=1 ";
		if(hotelId != null){
			hql = hql + "and hotelid="+hotelId;
		}
		if(userid != null){
			hql = hql + " and hmuserid='"+userid+"'";
		}
		if(state != null){
			hql = hql + "and state="+state;
		}
		hql = hql+"order by bindtime asc";
		return dao.findByHQL(hql);
	}

	@Override
	public void save(HotelHmanager hhm) {
		if(hhm.getId() != null){
			dao.update(hhm);
		}else{
			dao.save(hhm);
		}
		
	}

}
